<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>空明物联网服务平台</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/static/css/base.css" />
</head>


<body>
    <div class="container-fluid">
        <br />
        <!-- <h3><span class="glyphicon glyphicon-plus"></span> 设备详情</h3>
        <hr> -->
        <div class="panel panel-default">
            <div class="panel-heading">设备信息</div>
            <div class="panel-body" id="device_info">
                <div class="form-inline">
                    <p>设备名称：<span id="name"></span> <button type="button" class="btn btn-danger btn-xs"
                            onClick="deviceDel();"> 删除</button></p>
                </div>
                <p>设备UUID：<span id="uuid"></span></p>
                <p>设备SN ：<span id="sn"></span></p>
                <p>设备状态 ：<span id="status"></span></p>
                <p>添加时间：<span id="add_time"></span></p>
            </div>
        </div>

    </div>
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/base.js?version=1.0.0"></script>
    <script>
        /** isLoginStats(); **/

        var uuid = getUrlParam('uuid');
        console.log(uuid)

        function getDeviceInfo() {
            new AjaxRequest({
                type: "get",
                url: getServiceURL('deviceinfo'),
                param: {
                    "uuid": uuid
                },
                callBack: function (res) {
                    if (res.code == 0) {
                        var device_info = res.data.device_info;

                        $("#device_info #name").html(device_info.name);
                        $("#device_info #uuid").html(device_info.uuid);
                        $("#device_info #sn").html(device_info.sn);
                        $("#device_info #status").html(getDeviceStateText(device_info.status));
                        $("#device_info #add_time").html(device_info.add_time);
                    } else {
                        alert(res.msg);
                    }
                    console.log(res);
                }
            });
        }

        getDeviceInfo();

        function deviceDel() {
            if (confirm("是否确定要删除设备吗？删除后不可恢复")) {
                new AjaxRequest({
                    type: "post",
                    url: getServiceURL('devicedel'),
                    param: {
                        "uuid": uuid
                    },
                    callBack: function (res) {
                        if (res.code == 0) {
                            alert(res.msg);
                            //window.location.reload();
                            window.location.href="device.html";
                            return true;
                        }
                        alert(res.msg);
                        return false;
   
                    }
                });
            }
        }
    </script>
</body>

</html>